<?php
file_put_contents("post.log", var_export($_POST, true), FILE_APPEND);
file_put_contents("get.log", var_export($_GET, true), FILE_APPEND);
file_put_contents("input.log", file_get_contents("php://input") . "\n", FILE_APPEND);

die;
var_dump(checkSig(111));
function checkSig($data, $address = "127.0.0.1", $port = 55533)
    {
        $data  .= "\n";
        $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
        if ($socket < 0) {
            return false;
        }

        $result = socket_connect($socket, $address, $port);
        if ($result < 0) {
            return false;
        }

        $res = '';
        socket_write($socket, $data, strlen($data));
        while ($out = socket_read($socket, 2048)) {
            $res .= $out;
        }

        socket_close($socket);
        return (strtoupper(substr($res, 0, 1)) == "Y") ? true : false;
    }

var_dump(preg_match("/\d+/", "/notify/JianHangpay/1111", $matches));
var_dump($matches);


return;
$str = "POSID=034980415&BRANCHID=330000000&ORDERID=105002053991265190501001322574&PAYMENT=1000.00&CURCODE=01&REMARK1=&REMARK2=&ACC_TYPE=WX&SUCCESS=Y&TYPE=1&REFERER=&CLIENTIP=11.168.64.156&ACCDATE=20190501&SIGN=8513ab8320fce445c892df7d9b1f73f5eb70067b75fc633506495b785c46bbc47e2626875a437a959cc30fa4f8074161cf92ffe9d5eb2b83d66a44008a14bf6aa3c519441ffeb5a444801048085b9e6efe88c9d3c19a093e34c85b18a9776934e33a4b8db96272fa16bb9914817918871440fa33ee0ae6b9fbf72a0f5bb9aed5";
$strTmp = explode("&", $str);
$params = [];
foreach($strTmp as $item) {
    $itemArr = explode("=", $item);
    $params[$itemArr[0]] = $itemArr[1];
}

$key = "3fd2d57eea1668be490f51f3020111";

$sign = md5("POSID=034980415&BRANCHID=330000000&ORDERID=105002053991265190501001322574&PAYMENT=1000.00&CURCODE=01&REMARK1=&REMARK2=&ACC_TYPE=WX&SUCCESS=Y&TYPE=1&REFERER=&CLIENTIP=11.168.64.156&ACCDATE=20190501&KEY=" . $key);

var_dump($sign);



$arr = [
    'a' => 1,
    'b' => 2,
];
// var_dump(curl("http://localhost:8080/notify.php"));

function curl($url, $data)
    {

        header("Content-type: text/html; charset=utf-8");
        $curl = curl_init();
        //设置抓取的url
        curl_setopt($curl, CURLOPT_URL, $url);
        //设置获取的信息以文件流的形式返回，而不是直接输出。
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        //设置头文件的信息作为数据流输出
        curl_setopt($curl, CURLOPT_HEADER, 0);
        curl_setopt($curl,CURLOPT_CONNECTTIMEOUT,10);
        // 告诉curl禁用ssl当中的公用名,公用名只有两种值0表没有，1表示拥有，默认为1
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
        //设置post方式提交
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
        //为没有ssl所有不要进行认证的校验
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($curl, CURLOPT_HTTPHEADER, array(
                'Content-Type: application/x-www-form-urlencoded; charset=utf-8',
                'Content-Length: ' . strlen($data))
        );
        json_encode($data, JSON_UNESCAPED_UNICODE); //解决json处理传送中文问题
        //执行命令
        $str = curl_exec($curl);
        //关闭URL请求
        curl_close($curl);
        //把请求的数据进行返回
        return $str;
    }